﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CJJCH.Web
{
    public partial class StandardsDetails : System.Web.UI.Page
    {
        CJJCH.BLL.T_NET_MenuSecond bll_menusecond = new BLL.T_NET_MenuSecond();
        CJJCH.BLL.T_NET_MenuThird bll_third = new BLL.T_NET_MenuThird();
        CJJCH.BLL.T_NET_Consulting bll_consulting = new BLL.T_NET_Consulting();
        CJJCH.BLL.T_NET_Standards bll_standards = new BLL.T_NET_Standards();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitRepater();
                InitDataBind();
            }
        }

        private void InitRepater()
        {
            if (Request.QueryString["ID"] != null && LTP.Common.CheckInput.CheckGUID(Request.QueryString["ID"]))
            {
                lblID.Text = Request.QueryString["ID"].ToString();
            }
            if (Request.QueryString["firstid"] != null && LTP.Common.CheckInput.CheckDigit(Request.QueryString["firstid"].Trim()))
            {
                Top1.IIndex = Convert.ToInt32(Request.QueryString["firstid"].Trim());

                if (Request.QueryString["secondid"] != null && LTP.Common.CheckInput.CheckDigit(Request.QueryString["secondid"].Trim()))
                {
                    lblFID.Text = Request.QueryString["firstid"].Trim();
                    lblSID.Text = Request.QueryString["secondid"].Trim();
                    CJJCH.Model.T_NET_MenuSecond menusecond = new Model.T_NET_MenuSecond();
                    menusecond = bll_menusecond.GetModelListPane(Convert.ToInt32(lblFID.Text), Convert.ToInt32(lblSID.Text));
                    if (menusecond != null)
                    {
                        lblMID.Text = menusecond.MenuTypeID.ToString();
                        LeftMenu1.FirstId = menusecond.FirstID;
                        LeftMenu1.SecondId = menusecond.ID;
                        if (Request.QueryString["thirdid"] != null && LTP.Common.CheckInput.CheckDigit(Request.QueryString["thirdid"].Trim()))
                        {
                            if (Convert.ToInt32(Request.QueryString["thirdid"]) != 0)
                            {
                                lblTID.Text = Request.QueryString["thirdid"];
                                CJJCH.Model.T_NET_MenuThird menuthird = new Model.T_NET_MenuThird();
                                menuthird = bll_third.GetMinModelAgo(Convert.ToInt32(lblTID.Text));
                                lblTID.Text = menuthird.ID.ToString();
                                LeftMenu1.ThirdId = menuthird.ID;
                                lblmune.Text = menuthird.MenuName;
                            }
                            else
                            {
                                lblTID.Text = "0";
                                LeftMenu1.ThirdId = 0;
                                lblmune.Text = menusecond.MenuName;
                            }
                        }

                    }
                    else
                    {
                        Response.Redirect("error.aspx");
                    }
                }
                else
                {
                    lblFID.Text = Request.QueryString["firstid"].Trim();
                    CJJCH.Model.T_NET_MenuSecond menusecond = new Model.T_NET_MenuSecond();
                    menusecond = bll_menusecond.GetModelListPane(Convert.ToInt32(lblFID.Text), 0);
                    if (menusecond != null)
                    {

                        lblFID.Text = menusecond.FirstID.ToString();
                        lblSID.Text = menusecond.ID.ToString();
                        lblMID.Text = menusecond.MenuTypeID.ToString();
                        LeftMenu1.FirstId = menusecond.FirstID;
                        LeftMenu1.SecondId = menusecond.ID;
                        if (menusecond.HaveChild == true)//判断二级标题是否有子类如果有根据二级标题id获取到三级标题id如果无赋值为0
                        {
                            CJJCH.Model.T_NET_MenuThird menuthird = new Model.T_NET_MenuThird();
                            menuthird = bll_third.GetMinModel(menusecond.ID);
                            lblTID.Text = menuthird.ID.ToString();
                            LeftMenu1.ThirdId = menuthird.ID;
                            lblmune.Text = menuthird.MenuName;
                        }
                        else
                        {
                            lblTID.Text = "0";
                            LeftMenu1.ThirdId = 0;
                            lblmune.Text = menusecond.MenuName;
                        }
                    }
                    else
                    {
                        Response.Redirect("error.aspx");
                    }
                }
            }
            else
            {
                Response.Redirect("error.aspx");
            }




        }
        private void InitDataBind()
        {
            if (lblMID.Text != "")
            {
                CJJCH.Model.T_NET_MenuType type = new CJJCH.Model.T_NET_MenuType();
                type = (new BLL.T_NET_MenuType()).GetModelAgo(Convert.ToInt32(lblMID.Text));
                if (type != null)
                {
                    switch (Convert.ToInt32(lblMID.Text))
                    {
                        case 5:
                            divStandards.Style.Add(" display", "none");
                            divConsulting.Style.Add("display", "block");
                            bll_consulting.AddHits(new Guid(lblID.Text));
                            CJJCH.Model.T_NET_Consulting Consulting = new Model.T_NET_Consulting();
                            Consulting = bll_consulting.GetConsultingModel(new Guid(lblID.Text));
                            lstTitle.Text = Consulting.DataSource;
                            lblConsultinTitle.Text = Consulting.DataTitle;
                            lblConsultinName.Text = Consulting.DataSource;
                            lblConsultinAuthor.Text = Consulting.DataAuthor;
                            lblConsultinPlusDate.Text = Consulting.PlusDate.ToString("yyyy/MM/dd");
                            lblConsultinNote.Text = Consulting.DataNote;
                            break;
                        case 6:
                            divStandards.Style.Add(" display", "block");
                            divConsulting.Style.Add("display", "none");
                            bll_standards.AddHits(new Guid(lblID.Text));
                            CJJCH.Model.T_NET_Standards model = new Model.T_NET_Standards();
                            model = bll_standards.StandardsModel(new Guid(lblID.Text));
                            lstTitle.Text = model.DataName;
                            lblDataTitle.Text = model.DataTitle;
                            lblDataServiceID.Text = model.DataServiceID;
                            lblDataName.Text = model.DataName;
                            lblDataAuthor.Text = model.DataAuthor;
                            lblDataAbout.Text = model.DataAbout;
                            lblPlusDate.Text = model.PlusDate.ToString("yyyy/MM/dd");
                            lblDataSource.Text = model.DataSource;
                            lblDataAbout.Text = model.DataAbout;
                            lblDataNote.Text = model.DataNote;
                            break;
                        default:
                            break;
                    }


                }
                else
                {
                    LTP.Common.WindowClass.WindowBack("抱歉！您操作错误！");
                }
            }
        }

    }
}